home *** CD-ROM | disk | FTP | other *** search
/ AOL File Library: 4,401 to 4,500 / aol-file-protocol-4400-4401-to-4500.zip / AOLDLs / PDA-Newton Development / ND Newt Development Environm / newt-devenv-31.sit / applic2.nwt < prev    next >
Text File  |  1995-04-05  |  6KB  |  220 lines

  1. Notes
  2. {labels: 'NIL, viewFont: 10241} // nil=Unfiled, or specify a folder, e.g., 'Business.  remove viewFont for current Styles default
  3. //ERASE! in order to erase existing entries in this folder first
  4.  
  5. applic2.nwt -- Slurpee format
  6. 4/5/95
  7. Copyright 1994, 1995 S. Weyer.  All Rights Reserved Worldwide.
  8. To be distributed only with Newt 3.0 package
  9.  
  10. expanded MyApp example using more prototypes
  11. see applic0.nwt for simpler example
  12.  
  13. see applic3.nwt for same version as applic2.nwt but using
  14. earlier, more direct :addApp, :addStep syntax
  15. ----------
  16. MyApp2
  17. //:doObj('buildCO,'MyApp2)
  18. //:doObj('add,'MyApp2)
  19. //:doObj('remove,'MyApp2)
  20. {_proto: protoApp,
  21. title: "Hello World -- on Steroids",
  22. _package: {shortTitle: "Hello2"},
  23. }
  24. ----------
  25. MyApp2.protoNumberInputLine
  26. {_proto: protoInputLine,
  27. text: "enter a number",
  28. value: 0,
  29. viewFlags: 10753, //vVisible + vClickable + vGesturesAllowed + vNumbersAllowed
  30. viewChangedScript: func(slot,view)
  31.     if slot='text
  32.     then begin
  33.         value := StringToNumber(text);
  34.         if not value then value := 0;
  35.         if aTotal exists then aTotal:update();
  36.         end,
  37. viewSetupFormScript: func()
  38.     begin
  39.         self.text := clone(text);
  40.         self.value := 0;
  41.         inherited:?viewSetupFormScript();
  42.     end,
  43. }
  44. ----------
  45. MyApp2+float
  46. {_proto: protoFloatNGo,
  47. viewBounds: RelBounds(20,50,150,90),
  48. }
  49. ----------
  50. MyApp2.float+aboutText
  51. {viewclass: clParagraphView,
  52. text: "This wonderful application from the \"kitchen sink school of user interface design\" created by "&
  53.     :GetUserConfig('name) &      // the developer's name
  54.     ", with the help of Newt, the lizard wizard",
  55. viewFlags: 3, //vReadOnly+vVisible,
  56. viewBounds: RelBounds(5,5,140,80), // relative to aFloat
  57. }
  58. ----------
  59. MyApp2+button
  60. {_proto: protoTextButton,
  61. text: "About",
  62. viewBounds: RelBounds(20,30,40,16),
  63. buttonClickScript: func()
  64.     if float exists
  65.     then float:open()
  66.     else PlaySound(@102), // ROM_funbeep
  67. }
  68. ----------
  69. MyApp2+num1
  70. {_proto: protoNumberInputLine, // use user prototype defined in app
  71. text: "first number", // needs to be set so protos don't share text string
  72. viewBounds: RelBounds(130,20,100,20),
  73. }
  74. ----------
  75. MyApp2+num2
  76. {_proto: protoNumberInputLine,
  77. text: "second number",
  78. viewBounds: RelBounds(130,45,100,20),
  79. }
  80. ----------
  81. MyApp2+aTotal
  82. {_proto: protoStaticText,
  83. text: "Total",
  84. vars: ['num1, 'num2,], // same names as two fields
  85. viewBounds: RelBounds(130,80,100,16),
  86. update: func()
  87.     begin
  88.         local tot := 0, field;
  89.         foreach field in vars // add up num1.value+num2.value etc.
  90.         do tot := tot + GetVariable(self,field).value;
  91.         if round exists and round.viewValue
  92.         then tot := RIntToL(tot);
  93.         SetValue(self,'text,NumberStr(tot));
  94.     end,
  95. }
  96. ----------
  97. MyApp2+round
  98. {_proto: protoRCheckbox, // checkbox on right & text on left
  99. text: "Round?",
  100. indent: 40,
  101. viewBounds: RelBounds(10,78,50,16), 
  102. valueChanged: func() aTotal:update(),
  103. }
  104. ----------
  105. MyApp2+aTextval
  106. {_proto: protoStaticText,
  107. text: "xxx",
  108. viewBounds: RelBounds(150,240,100,16),
  109. }
  110. ----------
  111. MyApp2+labelLine
  112. {_proto: protoLabelInputLine,
  113. viewBounds: RelBounds(10,110,200,20),
  114. label: "a label",
  115. textSetup: func() clone("some string"), // initial value
  116. labelCommands: ["A", "B", "C"],  // optional
  117. textChanged: func()
  118.     SetValue(aTextval,'text,entryLine.text),
  119. }
  120. ----------
  121. MyApp2+picker
  122. {_proto: protoLabelPicker,
  123. text: "picker",
  124. viewBounds: RelBounds(10,140,100,16), 
  125. labelCommands: ["one", "two", "three",],
  126. labelActionScript: func(cmd)
  127.     SetValue(aTextval,'text,labelCommands[cmd]),
  128. }
  129. ----------
  130. MyApp2+slider
  131. {_proto: protoSlider,
  132. viewBounds: RelBounds(10,160,100,12),
  133. minValue: 1,
  134. maxValue: 3,
  135. viewSetupFormScript: func()
  136.     viewValue := (maxValue+minValue)/2,
  137. changedSlider: func()
  138.     SetValue(aTextval,'text,NumberStr(viewValue)),
  139. }
  140. ----------
  141. MyApp2+radiobuttons
  142. {_proto: protoRadioCluster,
  143. viewBounds: RelBounds(150,190,100,50),
  144. clusterChanged: func()
  145.     SetValue(aTextval,'text,NumberStr(clusterValue)),
  146. }
  147. ----------
  148. MyApp2.radiobuttons+ten
  149. {_proto: protoRadioButton,
  150. text: "diez",
  151. buttonValue: 10,
  152. viewBounds: RelBounds(0,0,60,15), // relative to radiobuttons
  153. }
  154. ----------
  155. MyApp2.radiobuttons+twenty
  156. {_proto: protoRadioButton,
  157. text: "veinte",
  158. buttonValue: 20,
  159. viewBounds: RelBounds(0,15,60,15),
  160. }
  161. ----------
  162. MyApp2.radiobuttons+thirty
  163. {_proto: protoRadioButton,
  164. text: "treinta",
  165. buttonValue: 30,
  166. viewBounds: RelBounds(0,30,60,15),
  167. }
  168. ----------
  169. MyApp2+textlist
  170. {_proto: protoTextlist,
  171. viewBounds: Relbounds(150,140,60,40),
  172. viewSetupFormScript: func()
  173.     begin 
  174.         self.listItems := ["larry","moe","curly"];
  175.         //viewLines := length(listItems);
  176.         :setupList() ;
  177.         inherited:?viewSetupFormScript();
  178.     end,
  179. viewLines: 3,
  180. buttonClickScript: func(i)
  181.     SetValue(aTextval,'text,listitems[i]),
  182. }
  183. ----------
  184. MyApp2+expando
  185. {_proto: protoExpandoShell,
  186. viewBounds: RelBounds(10,185,120,70),
  187. numLines: 2,
  188. viewFormat: 337, // vfFillWhite+vfFrameBlack+vfPen=1
  189. editHeight: 46, // height of expanded field
  190. editWidth: 80,
  191. indent: 50, // left edge of value
  192. myExpandoProto:
  193.     {_proto: protoTextExpando,
  194.     label: "a label",
  195.     path: 'var,
  196.     },
  197. viewSetupFormScript: func()
  198.     begin
  199.         local i, symslot;
  200.         self.target := self;
  201.         self.lines:=array(numLines,nil);
  202.         for i:=1 to numLines
  203.         do begin
  204.             symslot := intern("var"&i);
  205.             lines[i-1]:=
  206.                 {_proto: myExpandoProto,
  207.                 label: "Field "&i,
  208.                 path: symslot,  // e.g., 'var1
  209.                 };
  210.             SetValue(self,symslot,clone(""));
  211.             end;
  212.         inherited:viewSetupFormScript();
  213.     end,
  214. FlushEdits: func() nil, //inherited:?FlushEdits(), // no method to inherit?
  215. CloseEdit: func(view) // expanded field just closed
  216.     SetValue(aTextval,'text, target.(view.path)),
  217. }
  218. ----------
  219. BYE!
  220.